﻿@page "/user"
@using BBCore.Core.Models.Admins
@inject IDataService<UserEntity> IDataService
@inject IAdminService IAdminService
@inject SwalService SwalService
@attribute [TabItemOption(Text = "用户管理", Icon = "fa-fw fa-solid fa-desktop")]
<EasyAdminTable TItem="UserEntity" OnSaveAsync="OnSaveAsync" ShowExportButton="true" ShowExportPdfButton="true"  @ref="_adminTable">
    <TableColumns>       
        <TableColumn @bind-Field="@context.UserName" IsReadonlyWhenEdit="true" ValidateRules="UserRules" Filterable="true" Sortable="true"></TableColumn>
        <TableColumn @bind-Field="@context.NickName"></TableColumn>
        <TableColumn @bind-Field="@context.RoleId" Text="角色" LookupServiceKey="@BBCore_Constant.role_selectItems" Filterable="true"></TableColumn>
    </TableColumns>
    <ExportButtonDropdownTemplate Context="ExportContext">
        <div class="dropdown-item" @onclick="() => ExcelExportAsync(ExportContext)">
            <i class="fa-regular fa-file-excel"></i>
            <span>导出当前页数据 Excel</span>
        </div>
        <div class="dropdown-item" @onclick="() => ExcelExportAllAsync(ExportContext)">
            <i class="fa-regular fa-file-excel"></i>
            <span>导出全部数据 Excel</span>
        </div>
    </ExportButtonDropdownTemplate>
    <RowButtonTemplate Context="value">
        @if (value.UserName != BBCore_Constant.adminName)
        {
            <TableCellPopConfirmButton Color="Color.Danger" Text="重置密码" Content=@($"你是否要重置{value.UserName}的密码？") OnConfirm="() => ResetPassword(value)"></TableCellPopConfirmButton>
        }
    </RowButtonTemplate>

</EasyAdminTable>


